package com.luyue.zagj.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;
import com.luyue.zagj.R;
import com.luyue.zagj.domin.News;

/**
 * Created by luyue on 2016/11/21.
 *  * // 用News 实体类做演示，实际使用时 根据 接口传回数据做改变
 *   显示结果位演示 而是用随机数据 实际使用时候 使用List传回数据
        */

public class RepairViewHolder extends BaseViewHolder<News> {
    private TextView mTv_name;
    private ImageView mImg_face;
    private TextView mTv_sign;
    public RepairViewHolder(View itemView) {
        super(itemView);
    }

    public RepairViewHolder(ViewGroup parent) {
        super(parent, R.layout.news_recycler_item);
        mTv_name = $(R.id.person_name);
        mTv_sign = $(R.id.person_sign);
        mImg_face = $(R.id.person_face);
    }

    @Override
    public void setData(final News data) {
        int n= (int) (Math.random() * 2+1);
        switch (n){
            case 1:
                mTv_name.setText("到店维修");
                Glide.with(getContext())
                        .load(R.mipmap.repairr)
                        .placeholder(R.mipmap.ic_launcher)
                        .centerCrop()
                        .into(mImg_face);
                break;
            case 2:
                mTv_name.setText("上门维修");
                Glide.with(getContext())
                        .load(R.mipmap.repair1)
                        .placeholder(R.mipmap.ic_launcher)
                        .centerCrop()
                        .into(mImg_face);
                break;

            default:
                break;
        }


        //     mTv_name.setText(data.getTitle());



        mTv_sign.setText(data.getCtime());



//        Glide.with(getContext())
//                .load(data.getPicUrl())
//                .placeholder(R.mipmap.ic_launcher)
//                .centerCrop()
//                .into(mImg_face);
    }
}
